package edu.hunan.cxb18.controller;

import edu.hunan.cxb18.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * @author AuthorName
 * @create 2020-04-02 15:58
 */
@Controller
public class JSONTestController {
    @RequestMapping("/Jsontest")
    public @ResponseBody
    List<User> Jsontest(){
        List<User> users = new ArrayList<>();

        users.add(new User("haoren",250));
        users.add(new User("licy",250));
        users.add(new User("chen",250));
        users.add(new User("chuangbo",250));
        return users;
    }
    @RequestMapping(value = "/reqJsonTest",method = RequestMethod.POST)
    public  @ResponseBody String JsonTest01(@RequestBody User user){
        System.out.println(user);
        return "success";
    }
}
